package com.acwing.lc.part1;

/**
 * @author rkc
 * @date 2022/9/16 9:02
 */
public class LC53最大子数组和 {

    public int maxSubArray(int[] nums) {
        int[] f = new int[nums.length + 10];
        int ans = f[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            f[i] = Math.max(nums[i], f[i - 1] + nums[i]);
            ans = Math.max(ans, f[i]);
        }
        return ans;
    }
}
